package org.jeecg.modules.demo.znnqjc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.znnqjc.entity.ZwglZdfxzb;
import org.jeecg.modules.demo.znnqjc.mapper.ZwglZdfxfbMapper;
import org.jeecg.modules.demo.znnqjc.mapper.ZwglZdfxzbMapper;
import org.jeecg.modules.demo.znnqjc.service.IZwglZdfxzbService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 诊断分析
 * @Author: jeecg-boot
 * @Date: 2023-04-20
 * @Version: V1.0
 */
@Service
public class ZwglZdfxzbServiceImpl extends ServiceImpl<ZwglZdfxzbMapper, ZwglZdfxzb> implements IZwglZdfxzbService {

    @Autowired
    private ZwglZdfxzbMapper zwglZdfxzbMapper;
    @Autowired
    private ZwglZdfxfbMapper zwglZdfxfbMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        zwglZdfxfbMapper.deleteByMainId(id);
        zwglZdfxzbMapper.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for (Serializable id : idList) {
            zwglZdfxfbMapper.deleteByMainId(id.toString());
            zwglZdfxzbMapper.deleteById(id);
        }
    }


    /**
     * 按照年份获取诊断分析
     *
     * @param nianfen
     * @return
     */
    @Override
    public Result getzwzs(String nianfen) {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }
    @Override
    public Result getzwzsqb() {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzzgj(String nianfen) {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzwgc(String nianfen) {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzwzsa(String nianfen) {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzwzszdfxzuo(String nianfen) {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }

    @Override
    public Result getzwzszdfxyou(String nianfen) {
        QueryWrapper<ZwglZdfxzb> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("psrq", nianfen);
        List<ZwglZdfxzb> list = zwglZdfxzbMapper.selectList(queryWrapper);
        return Result.OK(list);
    }


}
